import fetch from '../assets/js/fetch'
import {getVilidAttrWithEmpty,isEmpty} from '../assets/js/assist'

/**
 *
 方法说明 获取代理列表
 *
 @method SYS_Module_update
 *
 @param  {Object} options 请求参数

 *
 @return {Object} 若code为0表示成功,返回data,执行then方法,否则执行catch方法
 */
export default function SYS_Module_update (options) {

  let _data = {
    Sno:"",//序号
    Type:"",//类型
    name:"",//标题
    text:"",//	内容
    text1:"",//内容1
    text2:"",//内容2
    text3:"",//内容3
    text4:"",//内容4
    text5:"",//内容5
    number:"",//数量
    height:"",//高度
    url:"",//视频地址
    auto_play:"",//自动播放
    img:"",//视频截图
    showFontType:"",//字体大小
    banner:"",//banner
    time:"",//时间
  };
  Object.assign(_data,options);

  _data.show = !!options.show ? 1: 0;
  // let str = "";
  // str = str + _data.Sno + "|";
  // str = str + _data.Type + "|";
  // str = str + _data.name + "|";
  // str = str + _data.text + "|";
  // str = str + _data.text1 + "|";
  // str = str + _data.text2 + "|";
  // str = str + _data.text3 + "|";
  // str = str + _data.text4 + "|";
  // str = str + _data.text5 + "|";
  // str = str + _data.number + "|";
  // str = str + _data.height + "|";
  // str = str + _data.url + "|";
  // str = str + _data.auto_play + "|";
  // str = str + _data.img + "|";
  // str = str + _data.showFontType + "|";
  // str = str + _data.banner + "|";
  // str = str + _data.time;

    return new Promise((resolve, reject) => {
        fetch({
            url:'/protocal/SYS_Module/update.ashx',
            method: 'post',
            data:_data
        }).then((result) => {
            const data = result.data;
            const total = result.total;
            const code = result.code;
            const message = result.msg;
            if (code == "1") {
                resolve(data,total);
            } else {
                reject(message);
            }
        })
        .catch((err) => {
            if (err) {
                console.log(err);
            }
            reject(err);
        });
    });
}
